﻿using System.Windows.Controls;

namespace KinonekoSoftware.Studio.Pages.Galleries.Teams
{

    [Associate(View = typeof(TeamGalleryView), ViewModel = typeof(TeamGalleryViewModel))]
    public partial class TeamGalleryView
    {
        public TeamGalleryView()
        {
            InitializeComponent();
        }


        protected override void OnViewModelMessaging(object parameter)
        {
            var vm = ViewModel<TeamGalleryViewModel>();
            if (parameter is null)
            {
                OpenButton.IsEnabled =
                        LockAndUnlockButton.IsEnabled =
                            RemoveButton.IsEnabled = vm.CurrentSelected is not null;

                if (vm.CurrentSelected is not null)
                {
                    var g = vm.CurrentSelected.IsLocked ? "FeatherIcon.Lock" : "FeatherIcon.Unlock";
                    LockAndUnlockButton.Icon = FindResource(g) as Geometry;
                }
            }

            if (parameter is not null)
            {
                NextPageButton.IsEnabled = vm.CanNextPage();
                PreviousPageButton.IsEnabled = vm.CanPreviousPage();
            }
        }
    }
}